package com.study.opcua.controller;

import com.study.opcua.utils.OpcClientUtil;
import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class TestController {

    @GetMapping("/test")
    public String test(){
        OpcUaClient client = OpcClientUtil.getClient("opc.tcp://127.0.0.1:49320");
        NodeId nodeId = new NodeId(2, "通道 1.设备 1.x");
        Object value = OpcClientUtil.readValue(client, nodeId);

        return "value: " + value;
    }
}
